package org.jdemo.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * ResourceUtil
 *
 * @author longlin(longlin@cyou-inc.com)
 * @date 2013-9-16
 * @since V1.0
 */
public class ResourceUtil {
    /**
     * 根据属性文件返回Properties对象
     *
     * @param resource
     * @return
     * @throws java.io.IOException
     */
    public static PropertiesResource getResourceAsProperties(String resource) {
        Properties props = new Properties();
        InputStream in = ResourceUtil.class.getResourceAsStream(resource);
        try {
            props.load(in);
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new PropertiesResource(props);
    }
}
